package com.tanhua.server.controller;

import com.tanhua.model.vo.PeachblossomVo;
import com.tanhua.server.service.SmallVideosService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 桃花传音
 */
@RestController
@RequestMapping("/peachblossom")
public class PeachblossomController {
    @Autowired
    private SmallVideosService smallVideosService;

    /**
     * 获取传音
     *
     * @return
     */
    @GetMapping
    public ResponseEntity getPeachblossom() {
        PeachblossomVo peachblossomVo = smallVideosService.getPeachblossom();
        return ResponseEntity.ok(peachblossomVo);
    }

    /**
     * 保存传音
     *
     * @return
     */
    @PostMapping
    public ResponseEntity postPeachblossom(MultipartFile soundFile) throws IOException {
        smallVideosService.savePeachblossom(soundFile);
        return ResponseEntity.ok(null);
    }
}
